function isObject(target){
    return target!=null&&typeof target=="object"
}
function trigger(){
    console.log('----触发视图更新-------');
}
export function reactive(target){
    if(!isObject(target)) return target
    const handle={
        set(target,key,value){ 
            console.log(target+"---->"+key+"---->"+target.hasOwnProperty("length"));
            if(target.hasOwnProperty(key)){
                trigger()
            }
            return Reflect.set(target,key,value)
        },
        get(target,key){
            console.log('key',key);
            const res=Reflect.get(target,key)
            if(isObject(target[key])){
                return reactive(res)
            }
            return res
        },
        deleteProperty(target,key){
            return Reflect.deleteProperty(target,key)
        }
    }
    const proxy=new Proxy(target,handle)
    return proxy
}